package com.newcapce.thread;

public class RunnableDemo {
    public static void main(String[] args) {
        Runnable runnable = new MyRunnable();
        Thread thread1 = new Thread(runnable);
        Thread thread2 = new Thread(runnable);
        thread1.start();
        thread2.start();
        System.out.println("我是主线程"+Thread.currentThread().getName());

    }
}

class MyRunnable implements Runnable{
    @Override
    public void run() {
        for(int i = 1; i <= 100; i++){
            System.out.println(i+":"+Thread.currentThread().getName());
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
